package com.plian.system.service.pf.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pf.PerformanceEffectDetail;
import com.plian.system.mapper.pf.PerformanceEffectDetailMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pf.IPerformanceEffectDetailService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: Take-off
 * @Description: TODO
 * @Date: 2023/1/16 11:01 AM
 * @Version: 1.0
 **/
@Slf4j
@Service
@AllArgsConstructor
public class PerformanceEffectDetailServiceImpl extends BaseServiceImpl<PerformanceEffectDetailMapper,PerformanceEffectDetail> implements IPerformanceEffectDetailService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<PerformanceEffectDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(PerformanceEffectDetail::getBasePerformanceId, ids);
        List<PerformanceEffectDetail> performanceEffectDetails = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(performanceEffectDetails)){
            return deleteLogic(performanceEffectDetails.stream().map(PerformanceEffectDetail::getId).collect(Collectors.toList()));
        }
        return true;
    }




}
